import {Controller, Get} from '@nestjs/common';
import {
  EmailServiceController,
  EmailServiceControllerMethods,
  type SendEmailRequest,
  SendEmailResponse,
} from '@libs/common/protos/email/email';
import { MicroEmailService } from './micro-email.service';
import { Metadata } from '@grpc/grpc-js';
import { Observable } from 'rxjs';
import { GrpcMethod } from '@nestjs/microservices';

// @EmailServiceControllerMethods()
@Controller()
export class MicroEmailController implements EmailServiceController{
  constructor(private readonly microEmailService: MicroEmailService) {}
  @GrpcMethod('EmailService', 'send')
  send(request: SendEmailRequest, metadata?: Metadata): Promise<SendEmailResponse> | Observable<SendEmailResponse> | SendEmailResponse {
    console.log('1',request)
    return this.microEmailService.sendWelcomeEmail(request);
  }







}
